<template>
  <div class="xiecheng">
    <div class="admin_main_block">

      <div class="admin_main_block_top">
        <div class="admin_main_block_left">
          <div>
            <el-input
              v-model="dataForm.member_username"
              :placeholder="i18n('common.please_input') + i18n('member.username')"
              clearable>
            </el-input>
          </div>
          <div>
            <el-input
              v-model="dataForm.member_nickname"
              :placeholder="i18n('common.please_input') + i18n('statistical.nickname')"
              clearable>
            </el-input>
          </div>
          <div>
            <el-button icon="Search" @click="getDataList(true)">
              {{ i18n('common.search') }}
            </el-button>
          </div>
        </div>
      </div>
      <div class="admin_table_main">
        <el-table
          :data="dataList"
          v-loading="dataListLoading"
          @selection-change="selectionChangeHandle">
          <el-table-column type="selection" header-align="center" align="center">
          </el-table-column>

          <el-table-column :label="i18n('member.username')">
            <template v-slot="scope">
              <span v-if="scope.row.member">{{ scope.row.member.username }}</span>
            </template>
          </el-table-column>

          <el-table-column :label="i18n('statistical.nickname')">
            <template v-slot="scope">
              <span v-if="scope.row.member">{{ scope.row.member.nickname }}</span>
            </template>
          </el-table-column>

          <el-table-column prop="create_time" :label="i18n('statistical.create_time')" width="160">
          </el-table-column>
        </el-table>
        <div class="admin_table_main_pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :page-size="pageSize"
            :total="totalPage"
            :current-page="pageIndex"
            background
            layout="prev, pager, next,jumper,total">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup name="statistical-online">
  import { useBase } from "@/hooks/base/useBase"
  import { useTable } from "@/hooks/table/useTable"

  const { router, i18n, isAuth } = useBase()

  const model = ref('statistical/online')
  const dataForm = reactive([
    'member_username',
    'member_nickname'
  ])

  const {
    dataList,
    pageIndex,
    pageSize,
    totalPage,
    dataListLoading,
    sizeChangeHandle,
    currentChangeHandle,
    selectionChangeHandle,
    getDataList,
  } = useTable(model.value, dataForm)

  onMounted(() => {
    getDataList(model)
  })
</script>
